package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SafetyExaminationPaperInfo;
import com.ruoyi.system.service.ISafetyExaminationPaperInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 试卷信息Controller
 * 
 * @author ruoyi
 * @date 2021-04-07
 */
@RestController
@RequestMapping("/system/examinationpaperinfo")
public class SafetyExaminationPaperInfoController extends BaseController
{
    @Autowired
    private ISafetyExaminationPaperInfoService safetyExaminationPaperInfoService;

    /**
     * 查询试卷信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:testpaperinformation:list')")
    @GetMapping("/list")
    public TableDataInfo list(SafetyExaminationPaperInfo safetyExaminationPaperInfo)
    {
        List<SafetyExaminationPaperInfo> list = safetyExaminationPaperInfoService.selectSafetyExaminationPaperInfoList(safetyExaminationPaperInfo);
        return getDataTable(list);
    }

    /**
     * 导出试卷信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:testpaperinformation:export')")
    @Log(title = "试卷信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SafetyExaminationPaperInfo safetyExaminationPaperInfo)
    {
        List<SafetyExaminationPaperInfo> list = safetyExaminationPaperInfoService.selectSafetyExaminationPaperInfoList(safetyExaminationPaperInfo);
        ExcelUtil<SafetyExaminationPaperInfo> util = new ExcelUtil<SafetyExaminationPaperInfo>(SafetyExaminationPaperInfo.class);
        return util.exportExcel(list, "examinationpaperinfo");
    }

    /**
     * 获取试卷信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:testpaperinformation:detail')")
    @GetMapping(value = "/{safetyExaminationPaperId}")
    public AjaxResult getInfo(@PathVariable("safetyExaminationPaperId") String safetyExaminationPaperId)
    {
        return AjaxResult.success(safetyExaminationPaperInfoService.selectSafetyExaminationPaperInfoById(safetyExaminationPaperId));
    }

    /**
     * 新增试卷信息
     */
    @PreAuthorize("@ss.hasPermi('system:testpaperinformation:add')")
    @Log(title = "试卷信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SafetyExaminationPaperInfo safetyExaminationPaperInfo)
    {
        return toAjax(safetyExaminationPaperInfoService.insertSafetyExaminationPaperInfo(safetyExaminationPaperInfo));
    }

    /**
     * 修改试卷信息
     */
    @PreAuthorize("@ss.hasPermi('system:testpaperinformation:edit')")
    @Log(title = "试卷信息", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody SafetyExaminationPaperInfo safetyExaminationPaperInfo)
    {
        return toAjax(safetyExaminationPaperInfoService.updateSafetyExaminationPaperInfo(safetyExaminationPaperInfo));
    }

    /**
     * 删除试卷信息
     */
    @PreAuthorize("@ss.hasPermi('system:testpaperinformation:remove')")
    @Log(title = "试卷信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{safetyExaminationPaperIds}")
    public AjaxResult remove(@PathVariable String[] safetyExaminationPaperIds)
    {
        return toAjax(safetyExaminationPaperInfoService.deleteSafetyExaminationPaperInfoByIds(safetyExaminationPaperIds));
    }
}
